package com.pp.controller;

import com.pp.entity.User;
import com.pp.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * Created by lanou on 18/2/27.
 */
@Controller
@RequestMapping("/")
public class LoginController {

    @Resource
    private UserService userService;

    @RequestMapping("goLogin")
    public String goLogin(){
        return "login";
    }

    @RequestMapping("login")
    @ResponseBody
    public boolean login(User user, HttpSession session){
        if(userService.findUser(user)==true){
            session.setAttribute("user",user);
            return true;
        }
        return  false;

    }
}
